package Arr;

import java.util.Scanner;

/**
 * @Author MDD
 * @Description
 * @Version
 * @Date
 **/
public class Code {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入想要的杨辉三角形的行数：");
        int n = sc.nextInt();
        int[][] arr = new int[n][n];
        //给每行数组的第一列和最后一列附值1
        for (int x = 0; x < arr.length; x++) {
            arr[x][0] = 1;
            arr[x][x] = 1;
        }
        //每行的每列数据都是上行的前一列数数据和这一列数据之和
        for (int x = 0; x < arr.length; x++) {
            for (int y = 1; y <= x-1; y++) {
                arr[x][y] = arr[x-1][y-1]+arr[x-1][y];
            }
        }
        //遍历二维数组，跟九九乘法表一样的遍历方式，右上角不要
        for (int x = 0; x < arr.length; x++) {
            for (int y = 0; y < x; y++) {
                System.out.print(arr[x][y]+"\t");
            }
            System.out.println("  ");
        }
    }
}
